/*    */ package cc.s2m.web.s2mBlog.controller.admin;
/*    */ 
/*    */ import cc.s2m.util.Page;
/*    */ import cc.s2m.web.s2mBlog.controller.base.BaseController;
/*    */ import cc.s2m.web.s2mBlog.pojo.SysConfig;
/*    */ import cc.s2m.web.s2mBlog.service.ISysConfig;
/*    */ import cc.s2m.web.s2mBlog.vo.Expressions;
/*    */ import cc.s2m.web.s2mBlog.vo.VO;
/*    */ import java.util.Date;
/*    */ import java.util.HashMap;
/*    */ import java.util.Map;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.ui.Model;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ import org.springframework.web.bind.annotation.ResponseBody;
/*    */ 
/*    */ @Controller("admin_SysConfigController")
/*    */ @RequestMapping({"/admin/sysConfig"})
/*    */ public class SysConfigController extends BaseController
/*    */ {
/*    */ 
/*    */   @Autowired
/*    */   private ISysConfig sysConfigService;
/*    */ 
/*    */   @RequestMapping(value={"/list"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String list(Model model, Integer page)
/*    */   {
/* 29 */     if (page == null) page = Integer.valueOf(1);
/* 30 */     Map map = new HashMap();
/* 31 */     Page pageBean = this.sysConfigService.getPage(page.intValue(), 50, null, map);
/* 32 */     model.addAttribute("pageBean", pageBean);
/* 33 */     return "admin/sysConfig";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/add"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String add(Model model, Integer id) {
/* 38 */     if (id != null) {
/* 39 */       SysConfig bean = (SysConfig)this.sysConfigService.selectByPrimaryKey(id);
/* 40 */       model.addAttribute("bean", bean);
/*    */     }
/* 42 */     return "admin/sysConfig_add";
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"/view"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public String view(Model model, Integer id) {
/* 47 */     if (id != null) {
/* 48 */       SysConfig bean = (SysConfig)this.sysConfigService.selectByPrimaryKey(id);
/* 49 */       model.addAttribute("bean", bean);
/*    */     }
/* 51 */     return "admin/sysConfig_view";
/*    */   }
/*    */   @RequestMapping(value={"/save"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String save(Model model, SysConfig bean) {
/* 57 */     if (bean == null) {
/* 58 */       return "empty";
/*    */     }
/* 60 */     if (bean.getId() == null)
/*    */     {
/* 62 */       SysConfig config = new SysConfig();
/* 63 */       config.setKey(bean.getKey());
/* 64 */       config = (SysConfig)this.sysConfigService.getByCondition(config);
/* 65 */       if (config != null) {
/* 66 */         return "exists";
/*    */       }
/* 68 */       bean.setType(Integer.valueOf(0));
/* 69 */       bean.setCreatAt(new Date());
/* 70 */       bean.setUpdateAt(new Date());
/* 71 */       this.sysConfigService.insert(bean);
/*    */     }
/*    */     else {
/* 74 */       SysConfig config = new SysConfig();
/* 75 */       config.setKey(bean.getKey());
/* 76 */       VO vo = new VO();
/* 77 */       vo.and(Expressions.ne("id", bean.getId()));
/* 78 */       config = (SysConfig)this.sysConfigService.getByCondition(config, vo);
/* 79 */       if (config != null) {
/* 80 */         return "exists";
/*    */       }
/* 82 */       bean.setUpdateAt(new Date());
/* 83 */       this.sysConfigService.updateByPrimaryKeySelective(bean);
/*    */     }
/* 85 */     return "success";
/*    */   }
/*    */   @RequestMapping(value={"/del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   @ResponseBody
/*    */   public String del(Integer id) {
/* 91 */     SysConfig bean = (SysConfig)this.sysConfigService.selectByPrimaryKey(id);
/* 92 */     if (bean != null) {
/* 93 */       this.sysConfigService.deleteByPrimaryKey(id);
/*    */     }
/* 95 */     return "success";
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\s2mBlog.zip
 * Qualified Name:     s2mBlog-3.0.0.WEB-INF.classes.cc.s2m.web.s2mBlog.controller.admin.SysConfigController
 * JD-Core Version:    0.6.1
 */